package com.wondertek.poms.core.service.impl;

import com.wondertek.poms.common.constant.Constants;
import com.wondertek.poms.common.service.impl.ServiceImpl;
import com.wondertek.poms.core.service.IAdvanceSaleService;
import com.wondertek.poms.dao.po.AdvanceSale;
import com.wondertek.poms.dao.repo.IAdvanceSaleDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author evan0213
 * @description
 */
@Service
public class AdvanceSaleServiceImpl extends ServiceImpl<AdvanceSale, Long> implements IAdvanceSaleService {
	@Autowired
	private IAdvanceSaleDao iAdvanceSaleDao;

	@Override
	public AdvanceSale deleteLogic(Long id) {
		AdvanceSale advanceSale = jpaRepository.getOne(id);
		AdvanceSale.putTimeAndUser(advanceSale);
		advanceSale.setDel(Constants.DELETE_1);
		jpaRepository.save(advanceSale);
		return advanceSale;
	}

	@Override
	public AdvanceSale merge(AdvanceSale model) {
		return null;
	}


	@Override
	public List<AdvanceSale> findAllByModelId(Long modelId) {
		return iAdvanceSaleDao.findAllByModelIdAndDel(modelId, Constants.DELETE_0);
	}
}
